# 代码编写者： 李朔
# 开发时间： 2021/7/31 11:20
nums=[3,2,4]

def twoSum(nums,target):
    nums_info,nums_len=[],len(nums)
    for i in range(nums_len):
        nums_info.append([nums[i],i+1])
    # print(nums_info)
    nums_info.sort(key=lambda x:x[0])
    print(nums_info)
    l_pointer,r_pointer=0,nums_len-1
    while l_pointer<r_pointer:
        sum_target=nums_info[l_pointer][0]+nums_info[r_pointer][0]
        if sum_target==target:
            if nums_info[l_pointer][1]<nums_info[r_pointer][1]:
                return [nums_info[l_pointer][1],nums_info[r_pointer][1]]
            else:
                return [nums_info[r_pointer][1],nums_info[l_pointer][1]]
        elif sum_target>target:
            r_pointer-=1
        else:
            l_pointer+=1

print(twoSum(nums,5))